MindFusion.Java Package Programmer's Guide
DiagramItem.as(T) Method
See Also
 






Down-casts the item to specified type.

Namespace: com.mindfusion.diagramming
Package: com.mindfusion.diagramming

 Syntax

Java  Copy Code

public <T> T as (
    Class<T> type
)

 Parameters

type

A Class instance specifying the target type.

 Return Value

This item cast to specified type, or null if it's of a different type.

 Remarks

Syntax sugar for a slightly shorter type checking and casting.

 Example

Java  Copy Code
public void nodeCreated(NodeEvent e)
{
    ContainerNode container = e.getNode().as(ContainerNode.class);
    if (container != null)
    {
        ...
    }
}

// alternative to

public void nodeCreated(NodeEvent e)
{
    if (e.getNode() instanceof ContainerNode)
    {
        ContainerNode container = (ContainerNode)e.getNode();
        ...
    }
}

 See Also

DiagramItem Members
DiagramItem Class
com.mindfusion.diagramming Namespace